﻿using System;
using chromium.GAE.Simple2Async;
using chromium.HTTP.Parser;
using chromium.Utils;

namespace chromium.HTTP.Runtime
{
    public class ProxyRuntime
    {
        private static readonly IAsyncHttpRequestHandler handler2 = new SimpleAsyncHandler2();

        static ProxyRuntime()
        {
            if (Settings.Mode == "xpp3")
            {
                handler2 = new SimpleAsyncHandler2();
            }
            else
            {
                handler2 = new SimpleAsyncHandler1();
            }
        }

        public static void Execute(HttpRequest request, HttpResponse response, AsyncCallback callback)
        {
            HandlerContext context = new HandlerContext(request, response, callback);

            handler2.BeginExecute(context);
        }
    }
}
